package ComLayer;

import java.util.LinkedList;
import java.util.Observable;

import util.DeviceInfo;

/**
 * Class ComunicationLayerControler
 */
public class ComunicationLayerControler extends Observable implements
		ComunicationLayerInterface, java.util.Observer {

	//
	// Fields
	//

	private ComunicationLayerInterface ComLayer;
	private int status = 0; // (0 off, 1 on)

	//
	// Constructors
	//
	public ComunicationLayerControler(ComunicationLayerInterface Comlayer) {
		ComLayer = Comlayer;
		// ComLayer.getObservable().addObserver(this);
	};

	//
	// Methods
	//

	//
	// Accessor methods
	//

	/**
	 * Set the value of ComLayer
	 * 
	 * @param newVar
	 *            the new value of ComLayer
	 */
	private void setComLayer(ComunicationLayerInterface newVar) {
		ComLayer = newVar;
	}

	/**
	 * Get the value of ComLayer
	 * 
	 * @return the value of ComLayer
	 */
	private ComunicationLayerInterface getComLayer() {
		return ComLayer;
	}

	//
	// Other methods
	//

	/**
	 * @return int
	 */
	public int sendText(String text) {
		return ComLayer.sendText(text);
	}

	@Override
	public DeviceInfo getDeviceInfo() {
		// TODO Auto-generated method stub
		return ComLayer.getDeviceInfo();
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		// TODO Auto-generated method stub
		System.out.println("Notificado CommunicationLayerControler");
		this.notifyObservers();
	}

	@Override
	public void addActionComand(DeviceInfo device, String Mensaje) {
		// TODO Auto-generated method stub

	}

	@Override
	public LinkedList<String> getListaacciones() {
		// TODO Auto-generated method stub
		return ComLayer.getListaacciones();
	}

	@Override
	public LinkedList<DeviceInfo> getDeviceList() {
		// TODO Auto-generated method stub
		return ComLayer.getDeviceList();
	}

	@Override
	public Observable getObservable() {
		// TODO Auto-generated method stub
		return ComLayer.getObservable();
	}

	@Override
	public int getStatus() {
		// TODO Auto-generated method stub
		return ComLayer.getStatus();
	}

	@Override
	public void setStatus(int statuss) {
		// TODO Auto-generated method stub
		ComLayer.setStatus(statuss);

	}
}
